#ifndef  FILE_UTILITY
#define  FILE_UTILITY

#include <fstream>
#include <sstream>
#include <iostream>
#include <string>

inline std::string read_file(const std::string &path) {
    std::fstream file;
    file.open(path, std::ios::in);
    if(!file) {
        std::cerr << "File not found: "<< path << std::endl;
        return "";
    }
    std::stringstream buffer; // 用于存储文件内容
    buffer << file.rdbuf(); // 将文件内容读取到 buffer
    file.close(); // 关闭文件

    if (buffer.fail()) { // 检查读取是否成功
        std::cerr << "Failed to read file: " << path << std::endl;
        return "";
    }

    return buffer.str(); // 返回文件内容
}

#endif